package com.eric.enderslastgame;

import android.graphics.Bitmap;
import android.graphics.Rect;
import android.util.Log;

public class Bugger {

	private static final String TAG = Bugger.class.getSimpleName();
	
	private Bitmap bitmap, miniBitmap;

	private int x, y; // Position
	private int velocity;
	private int vMultiplier = 1; // Velocity multiplier, used during space bar
									// acceleration
	private int width, height, miniWidth, miniHeight;
	private boolean visible;

	public Bugger(Bitmap bitmap, Bitmap miniBitmap, int xInitial, int yInitial, int velocity) {
		x = xInitial;
		y = yInitial;
//		this.velocity = velocity;
		this.velocity = 50;

		visible = true;

		this.bitmap = bitmap;
		this.miniBitmap = miniBitmap;

		width = bitmap.getWidth();
//		Log.d(TAG, "Bugger bitmap width is " + width);
		height = bitmap.getHeight();
//		Log.d(TAG, "Bugger bitmap height is " + height);
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public Rect getRect() {
		return new Rect(x, y, x + width, y + height);
	}

	public Bitmap getBitmap() {
		return bitmap;
	}
	
	public Bitmap getMiniBitmap() {
		return miniBitmap;
	}

	public void setBitmap(Bitmap bitmap) {
		width = bitmap.getWidth();
		height = bitmap.getHeight();
		this.bitmap = bitmap;
	}

	public boolean isVisible() {
		return visible;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	// Increase the velocity multiplier of the Bugger
	// TODO turn this into a function of time, the longer space bar gets held
	// down, higher vMultiplier
	public void accelerate() {
		vMultiplier = 2;
	}

	public void move() {
		y += velocity * vMultiplier;

		if (y > EndersGamePanel.panelHeight
				* EndersGamePanel.BOARD_HEIGHT_FRACTION) {
			visible = false;
//			Log.d(TAG, "Visible set to false. y is currently: " + y);
		}
	}
}
